import React, {PureComponent} from 'react';

class App extends PureComponent {

  constructor(props) {
    super(props);
    this.state = {
      counter: 101
    }
  }

  componentDidMount() {
    console.log("监听redux")
    document.title = this.state.counter
  }

  componentDidUpdate(prevProps, prevState, snapshot) {
    document.title = this.state.counter
  }

  componentWillUnmount() {
    console.log("取消监听redux")
  }

  render() {
    const { counter } = this.state
    return (
        <div>
          <h2>当前计数：{counter}</h2>
          <button onClick={() => this.setState({counter: counter + 1})}>+1</button>
        </div>
    );
  }
}

export default App;